<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!--新增医院-->
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>新增医院</title>
<link rel="shortcut icon" href="img/favicon.ico">
<!--STYLESHEET-->
<!--=================================================-->
<!--Roboto Slab Font [ OPTIONAL ] -->
<link
	href="http://fonts.googleapis.com/css?family=Roboto+Slab:400,300,100,700"
	rel="stylesheet">
<link
	href="http://fonts.googleapis.com/css?family=Roboto:500,400italic,100,700italic,300,700,500italic,400"
	rel="stylesheet">
<!--Bootstrap Stylesheet [ REQUIRED ]-->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!--Jasmine Stylesheet [ REQUIRED ]-->
<link href="css/style.css" rel="stylesheet">
<!--Font Awesome [ OPTIONAL ]-->
<link href="plugins/font-awesome/css/font-awesome.min.css"
	rel="stylesheet">
<!--Switchery [ OPTIONAL ]-->
<link href="plugins/switchery/switchery.min.css" rel="stylesheet">
<!--Bootstrap Select [ OPTIONAL ]-->
<link href="plugins/bootstrap-select/bootstrap-select.min.css"
	rel="stylesheet">
<!--Demo [ DEMONSTRATION ]-->
<link href="css/demo/jasmine.css" rel="stylesheet">
<!--SCRIPT-->
<!--=================================================-->
<!--Page Load Progress Bar [ OPTIONAL ]-->
<link href="plugins/pace/pace.min.css" rel="stylesheet">
<script src="plugins/pace/pace.min.js"></script>
</head>

<body>
	<div id="container"
		class="effect mainnav-sm navbar-fixed mainnav-fixed">
		<!--NAVBAR-->
		<!--===================================================-->
		<header id="navbar">
			<div id="navbar-container" class="boxed">
				<header id="navbar">
					<div id="navbar-container" class="boxed">
						<div class="navbar-content clearfix">
							<ul class="nav navbar-top-links pull-left">
								<li class="tgl-menu-btn"><a class="mainnav-toggle" href="#">
										<i class="fa fa-navicon fa-lg"></i>
								</a></li>
							</ul>
							<ul class="nav navbar-top-links pull-right">
								<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
								<li id="dropdown-user" class="dropdown"><a href="#"
									data-toggle="dropdown" class="dropdown-toggle text-right">
										<span class="pull-right"> <img
											class="img-circle img-user media-object" src="img/super.png"
											alt="Profile Picture">
									</span>
										<div class="username hidden-xs">super</div>
								</a></li>
							</ul>
						</div>
					</div>
				</header>
				<nav id="mainnav-container">
					<!--Brand logo & name-->
					<!--================================-->
					<div class="navbar-header">
						<a href="index.html" class="navbar-brand"> <i
							class="fa fa-forumbee brand-icon"></i>
						</a>
					</div>
					<div id="mainnav">
						<div id="mainnav-menu-wrap">
							<div class="nano has-scrollbar">
								<div class="nano-content" tabindex="0" style="right: -17px;">
									<ul id="mainnav-menu" class="list-group">
										<!--Category name-->
										<!--Menu list item-->
										<li><a href="superadminhomepage.jsp"
											data-original-title="" title=""> <i class="fa fa-home"></i>
										</a></li>
									</ul>
								</div>
								<div class="nano-pane" style="display: none;">
									<div class="nano-slider"
										style="height: 20px; transform: translate(0px, 0px);"></div>
								</div>
							</div>
						</div>
					</div>
				</nav>
			</div>
		</header>
		<!--===================================================-->
		<!--END NAVBAR-->
		<div class="boxed">
			<!--CONTENT CONTAINER-->
			<!--===================================================-->
			<div id="content-container">
				<div class="pageheader hidden-xs">
					<h3>
						<i class="fa fa-home"></i>医疗系统超级管理员界面
					</h3>
				</div>
				<!--Page content-->
				<!--===================================================-->
				<div id="page-content">
					<div class="row">
						<div class="col-lg-12">
							<div class="panel" style="margin-bottom: 0px;">
								<div class="panel-heading">
									<h3 class="panel-title">添加医院</h3>
								</div>
								<div class="panel-heading" style="margin-bottom: 0px;">
									<h5 class="panel-title" style="font-size: 15px;">-->填写基本信息</h5>
								</div>
							</div>

							<!--提交信息  -->
							<form action="../SuperAdminServlet" method="post" type="hidden"
								name="op" value="register">
								<div class="form-group" style="margin-bottom: 0px;">
									<input type="hidden" name="op" value="register"> <span
										class="panel-title" style="font-size: 15px; margin-left: 5%;">*请输入医院名称：</span>
									<label id="hospitalTip"></label> <span class="panel-title"
										style="font-size: 15px; margin-left: 30%;" id="exists"></span><label
										id="department"></label> <input id="demo-foo-hospital"
										type="text" placeholder="医院名字"
										class="form-control search-input"
										style="width: 40%; height: 30px; margin-left: 8%;"
										name="hospitalName">
								</div>
								<div class="form-group" style="margin-bottom: 0px;">
									<span class="panel-title"
										style="font-size: 15px; margin-left: 5%;">*请输入科室名称：</span> <input
										id="demo-foo-depart" type="text"
										placeholder="请将所有科室以左斜杠（/）进行隔开"
										class="form-control search-input"
										style="width: 40%; height: 30px; margin-left: 8%;"
										name="departmentName">
								</div>
								<span class="panel-title"
									style="font-size: 15px; margin-left: 5%;">请输入医院介绍：</span> <input
									id="demo-foo-content" type="text" placeholder="请输入简介"
									class="form-control search-input"
									style="width: 80%; height: 300px; margin-left: 8%;"
									name="hospitalContent">
								<button type="submit" class="btn btn-block btn-primary"
									style="width: 13%; margin-top: 30px; margin-left: 70%;"
									id="insert-hospital">提交</button>

							</form>


						</div>
					</div>
				</div>
			</div>
			<!--END MAIN NAVIGATION-->
		</div>
		<!-- FOOTER -->
		<!--===================================================-->
		<footer id="footer">
			<!-- Visible when footer positions are fixed -->
			<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
			<div class="show-fixed pull-right">
				<ul class="footer-list list-inline">
					<li>
						<p class="text-sm">SEO Proggres</p>
						<div class="progress progress-sm progress-light-base">
							<div style="width: 80%" class="progress-bar progress-bar-danger"></div>
						</div>
					</li>
					<li>
						<p class="text-sm">Online Tutorial</p>
						<div class="progress progress-sm progress-light-base">
							<div style="width: 80%" class="progress-bar progress-bar-primary"></div>
						</div>
					</li>
					<li>
						<button class="btn btn-sm btn-dark btn-active-success">Checkout</button>
					</li>
				</ul>
			</div>
			<!-- Visible when footer positions are static -->
			<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
			<div class="hide-fixed pull-right pad-rgt">Currently v1.0</div>
			<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
			<!-- Remove the class name "show-fixed" and "hide-fixed" to make the content always appears. -->
			<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
			<p class="pad-lft">jja2007 @2020医疗系统</p>
		</footer>
		<!--===================================================-->
		<!-- END FOOTER -->
		<!-- SCROLL TOP BUTTON -->
		<!--===================================================-->
		<button id="scroll-top" class="btn">
			<i class="fa fa-chevron-up"></i>
		</button>
		<!--===================================================-->
	</div>
	<!--===================================================-->
	<!-- END OF CONTAINER -->
	<!--JAVASCRIPT-->
	<!--=================================================-->
	<!--jQuery [ REQUIRED ]-->
	<script src="js/jquery-2.1.1.min.js"></script>
	<!--BootstrapJS [ RECOMMENDED ]-->
	<script src="js/bootstrap.min.js"></script>
	<!--Fast Click [ OPTIONAL ]-->
	<script src="plugins/fast-click/fastclick.min.js"></script>
	<!--Jquery Nano Scroller js [ REQUIRED ]-->
	<script src="plugins/nanoscrollerjs/jquery.nanoscroller.min.js"></script>
	<!--Metismenu js [ REQUIRED ]-->
	<script src="plugins/metismenu/metismenu.min.js"></script>
	<!--Jasmine Admin [ RECOMMENDED ]-->
	<script src="js/scripts.js"></script>
	<!--Switchery [ OPTIONAL ]-->
	<script src="plugins/switchery/switchery.min.js"></script>
	<!--Bootstrap Select [ OPTIONAL ]-->
	<script src="plugins/bootstrap-select/bootstrap-select.min.js"></script>
	<!--FooTable [ OPTIONAL ]-->
	<script src="plugins/fooTable/dist/footable.all.min.js"></script>
	<!--Fullscreen jQuery [ OPTIONAL ]-->
	<script src="plugins/screenfull/screenfull.js"></script>
	<!--FooTable Example [ SAMPLE ]-->
	<script src="js/demo/pages-directory.js"></script>
	<script>
		$(document).ready(function() {
			var op = "${param.op}";
			if (op == "error") {
				alert("医院注册成功！")
				location.href = "superinserthospital.jsp";
			}

			//对用户输入框失去焦点事件
			$("#demo-foo-hospital").blur(function() {
				var hospitalName = $(this).val();
				if (hospitalName.trim().length == 0) {
					$("#hospitalTip").text("此处不能为空");
					$("#hospitalTip").removeClass("success");
					$("#hospitalTip").addClass("error");
					//提交按钮禁用
					$("#insert-hospital").prop("disabled", true);
				} else {

					//发送异步请求
					$.ajax({
						async : true,
						url : "../SuperAdminServlet",
						type : "get",
						data : {
							op : "existOfHospitalName",
							hospitalName : hospitalName
						},
						dataType : "text",
						success : function(result) {
							console.log(result)
							if (result != "") {//医院已存在，不可新增
								$("#hospitalTip").text("医院已存在");
								$("#exists").text("当前医院已存在科室:");
								$("#hospitalTip").removeClass("success");
								$("#hospitalTip").addClass("error");
								showDepartment(result);//渲染科室信息
								//提交按钮禁用
								$("#insert-hospital").prop("disabled", true);
							} else if ("" == result) {//医院不存在，可以新增
								$("#hospitalTip").text("请输入科室");
								$("#exists").text("");
								$("#hospitalTip").removeClass("success");
								$("#hospitalTip").addClass("error");
								//提交按钮禁用
								$("#insert-hospital").prop("disabled", false);
							}
						},
						error : function() {
							alert("异步请求失败");

						}

					});

				}

			});
			//科室信息渲染
			function showDepartment(result) {
				//result  后端传出来的json格式的字符串
				//JSON.parse(result)  作用:将json格式字符串成js对象
				$.each(JSON.parse(result), function(index, items) {
					$("#department").text(items.departmentName;                                              
					)
				})
			}
			;
		});
	</script>
</body>

</html>